using System;
using System.Collections.Generic;
using System.Text;
using Rapier.Kodachi.Shared;
using System.Drawing;
using System.Runtime.InteropServices;

namespace Rapier.Kodachi.SystemCommands.Actions
{
    public class Suspend : Action
    {
        [DllImport("PowrProf.dll")]
        public static extern bool SetSuspendState(bool Hibernate, bool ForceCritical, bool DisableWakeEvent);

       private Bitmap suspendImage; 

        #region Constructor
        public Suspend(Plugin plugin)
            : base(plugin, "Rapier.Kodachi.SystemCommands.Suspend", "Suspend / Sleep", "Suspend/Sleep Windows.")
        {
            suspendImage = Rapier.Kodachi.SystemCommands.Properties.Resources.Suspend.ToBitmap();
            this.IndirectItemUse = IndirectItemUse.None;
            GetImage = delegate()
            {
               return suspendImage;
            };
        }
        #endregion

        #region Action Members
        public override void Execute(Item[] directItems, Item[] indirectItems)
        {
            SetSuspendState(false, true, false);
        }

        public override bool IsValidIndirect(Item indirectItem)
        {
            return false;
        }

        public override bool IsValidDirect(Item directItem)
        {
            return directItem.Properties.ContainsKey("SystemCommand") && (bool)(directItem.Properties["SystemCommand"]) == true;
        }
        #endregion
    }
}
